#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)
#define epr(i, x, y) for(int i = h[x], y = e[i].v; i; i = e[i].nxt, y = e[i].v)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e6 + 10;
const int inf = 0x3f3f3f3f;

int n, m;

namespace F {
	const int N = 410;
	const int M = 1e5 + 10;
	struct edge {
		int v, w, c, nxt;
	} e[M];
	int cnt = 1, h[N], s, t, incf[N], pre[N], dis[N];
	bool v[N];
	ll maxflow, ret;
	void tlink(int u, int v, int w, int c) { e[++cnt] = (edge) { v, w, c, h[u] }; h[u] = cnt; }
	void link(int u, int v, int w, int c) { tlink(u, v, w, c), tlink(v, u, 0, -c); }
	void setst(int _s, int _t) { s = _s, t = _t; }
	bool bfs() {
		memset(v, 0, sizeof v); memset(dis, 0x3f, sizeof dis); queue < int > q; q.ep(s); incf[s] = inf; dis[s] = 0; v[s] = true;
		while(q.size()) {
			int x = q.front(); q.pop();
			for(int i = h[x], y; i; i = e[i].nxt)
				if(e[i].w && dis[y = e[i].v] > dis[x] + e[i].c) {
					pre[y] = i; incf[y] = min(e[i].w, incf[x]); dis[y] = dis[x] + e[i].c;
					if(!v[y]) q.ep(y), v[y] = true;
				}
			v[x] = false;
		}
		if(dis[t] < inf) return true;
		return false;
	}
	void update() {
		int x = t; maxflow += incf[t]; ret += incf[t] * dis[t];
		while(x != s) {
			int i = pre[x];
			e[i].w -= incf[t]; e[i ^ 1].w += incf[t];
			x = e[i ^ 1].v;
		}
	}
	void runit() {
		ret = maxflow = 0; while(bfs()) update();
	}
}

int main() {
#ifdef YJR_2333_TEST
	freopen("1.in", "r", stdin);
#endif
	n = in, m = in; int s = 1, t = n;
	F :: setst(s, t);
	rep(i, 1, m) {
		int u = in, v = in, w = in, c = in;
		F :: link(u, v, w, c);
	}
	F :: runit(); cout << F :: maxflow << " " << F :: ret << endl;
	return 0;
}
